package com.jic.member.entity.model;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jic.common.base.tuple.Tuple;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * description: TripBranchNode
 * date: 2020/6/8 16:12
 * author: wangys
 * version: 1.0
 */
@Data
@Accessors(chain = true)
public class TripBranchNode {
    /*
     * 主键id
     */
    private Long id;


    /*
     * 旅程分支节点code
     */
    private String nodeCode;


    /*
     * 节点模板id
     */
    private Long nodeTemplateId;


    /*
     * 节点模板code
     */
    private String nodeTemplateCode;


    /*
     * 旅程分支id
     */
    private Long branchId;


    /*
     * 上级节点id
     */
    private Long prevBranchNodeId;

    /**
     * 上级节点TemplateCode
     */
    private String  prevBranchTemplateCode;


    /*
     * 节点变量
     */
    private String nodeVariable;


    /*
     * 事件类型
     */
    private Integer eventType;

    /*
     * 事件code
     */
    private String eventCode;

    /*
     * 分支条件：0、无，1、是，2、否
     */
    private Integer branchCondition;

    //旅程id
    private Long tripId;


    public static void main(String[] args) {
        Tuple<Long, Long> dateRange = new Tuple();
        dateRange.setS(new Date().getTime());
        dateRange.setF(new Date().getTime());
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("eventRangeTime", dateRange);
        JSONArray array = new JSONArray();
        array.add(jsonObject);

        String s = JSONArray.toJSONString(array);
        JSONArray jsonArray = JSONArray.parseArray(s);
        for (int i = 0; i < jsonArray.size(); i++) {
            JSONObject param = (JSONObject)jsonArray.get(0);
            Tuple<Long, Long> eventRangeTime = param.getObject("eventRangeTime", Tuple.class);
            if(eventRangeTime != null){
                long start = eventRangeTime.getF();
                long end = eventRangeTime.getS();
                long now = System.currentTimeMillis();
            }
        }
    }

}
